package com.jinghangzz.shop.goods.util;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Callable;

import com.jinghangzz.shop.common.util.ConstatFinalUtil;
import com.jinghangzz.shop.goods.pojo.AGoodsCate;
import com.jinghangzz.shop.goods.service.IGoodsOperService;

/**
 * 多线程的工具类
 * @author TeaBig
 *
 */
public class ServiceCallableUtil implements Callable<Object>
{
	/**
	 * 多线程的操作类型
	 */
	private String operType ; 
	/* 多线程使用到的一些参数 */
	private Map<String,Object> paramsMap = new HashMap<String, Object>();

	/**
	 * Runnable中的run方法
	 * 启动多线程,
	 * new Thread().start();多线程启动
	 * new Thread().run();方法调用
	 */
	@Override
	public Object call() throws Exception
	{
		ConstatFinalUtil.SYS_LOGGER.info("---启动多线程---");
		if("batchSpider".equalsIgnoreCase(operType))
		{
			/* 批量抓取京东的商品列表 */
			IGoodsOperService goodsOperService = (IGoodsOperService) paramsMap.get("goodsOperService") ; 
			AGoodsCate currCate = (AGoodsCate) paramsMap.get("currCate") ; 
			int stRecord = (int) paramsMap.get("stRecord") ; 
			int edRecord = (int) paramsMap.get("edRecord") ; 
			goodsOperService.operBatchJdThread(currCate, stRecord, edRecord);
		}
		ConstatFinalUtil.SYS_LOGGER.info("---结束多线程---");
		return null;
	}

	public void setOperType(String operType)
	{
		this.operType = operType;
	}

	public void setParamsMap(Map<String, Object> paramsMap)
	{
		this.paramsMap = paramsMap;
	}
}
